import request from '@/utils/request'

/**
 * 获取组织的数据
 */
export const reqGetDepartments = () => {
  return request.get('/company/department')
}

// 根据id删除部门
export const reqDelDepartments = (id) => {
  return request.delete(`/company/department/${id}`)
}

// 新增部门
export const reqAddDepartments = (data) => {
  return request.post('/company/department', data)
}

// 正常情况：渲染时返回的数据，不会包含完整的详情数据！！！编辑时，需要请求详情的数据
// 根据id获取部门详情
export const reqGetDepartDetail = (id) => {
  return request.get(`/company/department/${id}`)
}

// data => form对象, 对于修改而言，form对象中在回显时，会加上id属性
// 根据id提交修改的申请
export const reqUpdateDepartments = (data) => {
  return request.put(`/company/department/${data.id}`, data)
}
